package com.sali.b_design_pattern.f_responsibility_pattern.strategy.method01;

import org.springframework.stereotype.Component;

@Component
public class JobScheduler {

    public void jobExec(String param) {
        try {
            JobHandlerParams jobHandlerParams = new JobHandlerParams();
            jobHandlerParams.setParamA(param);

            // 参数初始化
            JobHandler.Builder builder = new JobHandler.Builder();
            // 预执行，检查参数
            builder.addHandler(new CheckParamsJobHandler(jobHandlerParams));
            // 启动/执行任务
            builder.addHandler(new RunningJobHandler(jobHandlerParams));

            builder.build().doHandler();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
